package com.dnjn.happiness.system.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.system.api.RemoteRoleService;
import com.dnjn.happiness.system.api.domain.SysRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Component
public class RemoteRoleFallbackFactory implements FallbackFactory<RemoteRoleService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteRoleFallbackFactory.class);
    @Override
    public RemoteRoleService create(Throwable throwable) {
        log.error("调用角色服务失败: " + throwable.getMessage());
        return new RemoteRoleService() {
            @Override
            public R<List<SysRole>> queryRole(Long userId, String source) {
                return R.fail("查询角色列表失败: {}" + throwable);
            }

            @Override
            public R<List<SysRole>> selectRolePermissionByUserId(Long userId, String source) {
                return R.fail("查询角色信息失败: {}" + throwable);
            }
        };
    }
}
